import request from '@/http/request';

const getCourses = () => {
    return request({
        url: '/list',
        method: 'get'
    })
}

const getCourseById = (id) => {
    return request({
        url: '/getCourseNameById',
        method: 'get',
        params: {
            courseId: id
        }
    })
}

const getCourseByName = (name) => {
    return request({
        url: '/getCourseIdByName',
        method: 'get',
        params: {
            name: name
        }
    })
}

const updateCourse = (course) => {
    return request({
        url: '/updateCourse',
        method: 'put',
        data: course
    })
}

const deleteCourse = (id) => {
    return request({
        url: '/deleteCourse',
        method: 'delete',
        params: {
            courseId: id
        }
    })
}

const addCourse = (course) => {
    return request({
        url: '/addCourse',
        method: 'post',
        data: course
    })
}

export default{
    getCourses,
    getCourseById,
    getCourseByName,
    updateCourse,
    deleteCourse,
    addCourse
}
